package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.core.domain.entity.SysUser;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.front.system.domain.business.dto.Sorter;
import com.lvy.hczn.front.system.service.ISysUserService;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.domain.dto.cteck.DeliveryOrderInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RequestMapping("/api/dt/user/")
@RestController
@Slf4j
public class TSysUserController {

    @Autowired
    private ISysUserService sysUserService;


    @ApiOperation(value = "同步分拣员账户更新到本地", notes = "同步分拣员账户更新到本地")
    @PostMapping("data")
    public AjaxResult syncSorterFromTransmit(HttpServletRequest request, @RequestBody List<ParamInfo<Sorter>> list) {
        try {
            sysUserService.syncSorterFromTransmit(list);
            return AjaxResult.success();
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("syncSorterFromTransmit同步异常：{}", e);
                return AjaxResult.error("系统异常");
            }
        }
    }
}
